# Maintainer: Oscar Fuentes <ofv@wanadoo.es>

_realname=ctags
pkgbase=mingw-w64-universal-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
pkgver=6.0.0
pkgrel=1
pkgdesc='Generates an index file of language objects found in source files (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}"
          "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}"
           "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
replaces=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
url='https://ctags.io/'
license=('spdx:GPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-python-docutils"
             "${MINGW_PACKAGE_PREFIX}-autotools")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-jansson"
         "${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libyaml"
         "${MINGW_PACKAGE_PREFIX}-pcre2")
source=("https://github.com/universal-ctags/ctags/releases/download/v${pkgver}/universal-ctags-${pkgver}.tar.gz")
sha256sums=('aa549b6c1210f3f3443adbd8f3c95650cd2313db08aa3e7641c5ea1a9fa6c8b3')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"universal-${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --disable-etags \
    --disable-external-sort

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/universal-${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/universal-${_realname}/COPYING"
}
